package test;

import java.lang.annotation.Target;
import java.lang.reflect.Array;
import java.util.Arrays;

import org.junit.Test;

public class erfenchazhao {
	public static void main(String[] args) {
		int[] scores={0,0,1,2,3,5,4,5,2,8,7,6,9,5,4,8,3,1,0,2,4,8,7,9,5,2,1,2,3,9};
		for (int i = 1; i <= scores.length-1; i++) {
			for (int j = 0; j < scores.length-i; j++) {
				if(scores[j]>scores[j+1]) {
					int a = scores[j];
					scores[j]=scores[j+1];
					scores[j+1]=a;
				}
			}
		}
		System.out.println(Arrays.toString(scores));
	}
	@Test
	public void text1() {
		int [] scores = {8 ,17 , 19 , 37 , 40 , 73 , 79 , 82 , 87 , 95 , 97 , 98};
		int position = Array(scores,73);
		System.out.println(position);
	}
	private int Array(int[] scores, int target) {
		int low = 0;
		int high = scores.length - 1;
		while (low<= high) {
			int middle = (low + high)/2;
			if (target == scores[middle]) {
				return middle;
			}else if (target < scores[middle]) {
				high = middle - 1;
			}else if (target > scores[middle]) {
				high = middle + 1;
			}
		}
		return -1;
	}
}
